package ge.modules.drawables;

/**
 * 	
 * @author Abel
 *	Represents the information of one color.
 *  v1 The color is represented like RGB parameters.
 */
public class Color 
{
	private int R,G,B,A;
	private float maxValue = 255f;
	/**
	 * 	Constructs a new color with RGB parameters
	 *  between 0-255
	 * @param r Red
	 * @param g Green 
	 * @param b Blue
	 * @param a Alpha
	 */
	public Color(int r, int g, int b, int a)
	{
		R = (int) Math.min( Math.max(r,0),maxValue);
		G = (int) Math.min( Math.max(g,0),maxValue);
		B = (int) Math.min( Math.max(b,0),maxValue);
		A = (int) Math.min( Math.max(a,0),maxValue);
	}
	/**
	 * 	Constructs a new color with RGB parameters
	 *  between 0-255
	 * @param r Red
	 * @param g Green 
	 * @param b Blue
	 */
	public Color(int r, int g, int b)
	{
		R = (int) Math.min( Math.max(r,0),maxValue);
		G = (int) Math.min( Math.max(g,0),maxValue);
		B = (int) Math.min( Math.max(b,0),maxValue);
		A = 255;
	}
	
	/**
	 * 	 Default color is black
	 */
	public Color()
	{
		R = B = G = 0;
		A = 255;
	}
	/**
	 * 
	 * @return Red Value
	 */
	public int getR() {
		return R;
	}
	/**
	 * 
	 * @return Green Value
	 */
	public int getG() {
		return G;
	}
	/**
	 * 
	 * @return Blue Value
	 */
	public int getB() {
		return B;
	}
	/**
	 * @return the Alpha value
	 */
	public int getA()
	{
		return A;
	}
	/**
	 * 	This function wants to improve the DrawEngine avoiding to change to the color state
	 * 	when the new color is the default one.
	 * @return True if it's the default color
	 */
	public boolean isBlack()
	{
		return R == 0 && G == 0 && B == 0 && A == 255;
	}
}
